import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/api/user/login/',
    method: 'post',
    data
  })
}

export function register(data) {
  return request({
    url: '/api/user/register/',
    method: 'post',
    data
  })
}

export function getInfo() {
  return request({
    url: '/api/user/',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/api/user/logout/',
    method: 'post'
  })
}

export function changeUserInfo({ nick_name, phone, gender, icon }) {
  return request({
    url: '/api/user/',
    method: 'put',
    data: { nick_name, phone, gender, icon }
  })
}

export function getUserList() {
  return request({
    url: '/api/user/list/',
    method: 'get'
  })
}

export function deleteUser({ id }) {
  return request({
    url: `/api/user/list?id=${id}`,
    method: 'delete'
  })
}